package com.mlnx.stream.listener.iml;

import com.mlnx.common.utils.MyLog;
import com.mlnx.data.entity.BpInfo;
import com.mlnx.data.service.BpDataService;
import com.mlnx.stream.listener.BpListener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

import cn.hutool.core.date.DateUtil;

/**
 * Created by amanda.shan on 2019/10/27.
 */
@Component
public class BpStoreListener implements BpListener {

    private MyLog log = MyLog.getLog(getClass());

    @Autowired
    private BpDataService bpDataService;

    @Override
    public void receiveBpInfo(BpInfo bpInfo) {

        bpDataService.save(bpInfo);
        log.info("保存BP 病人ID：{} {}/{}-{} {}", bpInfo.getPatientId(),
                bpInfo.getSbp(), bpInfo.getDbp(), bpInfo.getHeart(),
                DateUtil.formatDateTime(new Date(bpInfo.getTime())));
    }

}
